home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 138
/
Volume 138 Aug 19 2011 - Damaged.iso
/
Games
/
the_independent.swf
/
scripts
/
frame_5
/
DoAction_4.as
< prev
next >
Wrap
Text File
|
2011-08-19
|
9KB
|
361 lines
function float()
{
if(hitEnd == 1)
{
this.xAcc *= -1;
this._xscale *= -1;
}
this._x += this.xAcc - WXacc;
this._y += mRd(2 * math.sin(this.yAcc) - WYacc);
this.relX += this.xAcc;
this.yAcc += 0.05;
if(this.relX > 1750)
{
this.relX = 1750;
this.xAcc *= -1;
this._xscale *= -1;
}
else if(this.relX < 0)
{
this.relX = 0;
this.xAcc *= -1;
this._xscale *= -1;
}
if(paper != undefined)
{
if(this.hittest(paper._x,paper._y,false))
{
if(this["class"] == "pigeon" && pigeonHit != this.num)
{
_global.score += 25;
pigeonHit = this.num;
this.gotoandplay("hit");
updatescore();
this.xAcc *= -1;
this._xscale *= -1;
playFX("hitPigeon");
}
}
}
}
function control()
{
WXacc = mRd(mMx(mMn((this.targ._x - 250) / 10,20),-20));
if(this._y < 400)
{
WYacc = mRd(mMx(mMn((this.targ._y - 200) / 10,20),-20));
}
else if(this._y > 400)
{
WYacc = 400 - this._y;
}
if(this._y == 400)
{
if(mRd(mMx(mMn((this.targ._y - 200) / 10,20),-20)) < 0)
{
WYacc = mRd(mMx(mMn((this.targ._y - 200) / 10,20),-20));
}
else
{
WYacc = 0;
}
}
this._x += WXacc;
this._y += WYacc;
ground._y -= WYacc;
bkgrnd._y = ground._y / 2 - 475;
if(WXacc == 0)
{
if(_global.section == 2)
{
_root.sectionStart(3);
}
else if(_global.section == 5)
{
_root.sectionStart(6);
}
}
if(WXacc > 0)
{
curOb = oForeBuild;
if(this._x + 400 > curOb.aPos[curOb.nextBuild])
{
if(curOb.aPos[curOb.nextBuild] != undefined)
{
addNextBuilding(curOb,this._x + 400 - curOb.aPos[curOb.nextBuild]);
}
}
curOb = oBackBuild;
if(this._x + 400 > curOb.aPos[curOb.nextBuild])
{
if(curOb.aPos[curOb.nextBuild] != undefined)
{
addNextBuilding(curOb,this._x + 400 - curOb.aPos[curOb.nextBuild]);
}
}
}
else
{
curOb = oForeBuild;
if(this._x - 400 < curOb.aPos[curOb.prevBuild])
{
if(curOb.aPos[curOb.prevBuild] != undefined)
{
addPrevBuilding(curOb,this._x - 400 - curOb.aPos[curOb.prevBuild]);
}
}
curOb = oBackBuild;
if(this._x - 400 < curOb.aPos[curOb.prevBuild])
{
if(curOb.aPos[curOb.prevBuild] != undefined)
{
addPrevBuilding(curOb,this._x - 400 - curOb.aPos[curOb.prevBuild]);
}
}
}
}
function move()
{
this._x -= WXacc * this["class"].para;
this._y -= WYacc;
this["class"].curY = this._y;
if(this._x < -150)
{
this["class"].prevBuild = this.num;
this["class"].aPos[this.num] = controller._x - 400;
this.removeMovieClip();
}
if(this._x > 650)
{
this["class"].nextBuild = this.num;
this["class"].aPos[this.num] = controller._x + 400;
this.removeMovieClip();
}
}
function movePeople()
{
this._x -= WXacc;
this._y -= WYacc;
if(this.hittest(paper._x,paper._y,false))
{
checkHit(this);
}
}
function search()
{
this._x -= WXacc;
this._y -= WYacc;
}
function checkHit(ob)
{
if(ob["class"] == oPeople && ob.person._currentframe == 1)
{
ob.person.play();
peopleHit();
controller.targ = ob;
paper.removeMovieClip();
}
else if(ob["class"] == oObstacles && _global.lastOb != ob.num && _global.breakout < 30)
{
_global.breakout = _global.breakout + 1;
_global.lastOb = ob.num;
if(paper.relY > 290)
{
_global.potScore -= mRd(mAb(paper.Xacc));
paper.Xacc *= -0.8;
paper.rot *= -0.8;
playFX("hitTree");
}
else
{
if(paper.Yacc > 0)
{
_global.potScore -= mRd(mAb(paper.Yacc));
paper.Yacc *= -0.5;
paper.rot *= 0.8;
}
else
{
_global.potScore -= mRd(mAb(paper.Xacc));
paper.Yacc = - mAb(paper.Xacc * 0.5);
paper.Xacc = mAb(paper.Yacc * 0.5);
paper.rot *= 0.8;
}
playFX("hitLamp");
}
}
else if(ob["class"] == oBaddy)
{
ob.play();
baddyHit();
controller.targ = ob;
paper.removeMovieClip();
}
}
function baddyHit()
{
_global.peopleScore = _global.peopleScore + 1;
scoreBar["icon" + _global.peopleScore].gotoandstop(3);
_global.score -= 50;
updateScore();
playFX("hitBad");
}
function peopleHit()
{
_global.peopleHit = _global.peopleHit + 1;
_global.peopleScore = _global.peopleScore + 1;
scoreBar["icon" + _global.peopleScore].gotoandstop(2);
_global.score += _global.potScore;
updateScore();
playFX("hitGood");
}
function updateScore()
{
scoreBar.score.text = _global.score;
}
function moveTrail()
{
this._x -= WXacc;
this._y -= WYacc;
this._alpha -= 2;
if(this._alpha <= 0)
{
this.removeMovieClip();
}
}
function moveArrow()
{
this._x -= WXacc;
this._y -= WYacc;
if(!Key.isDown(17))
{
this._visible = true;
viewingArrows._visible = false;
searcher._x = paperBoy._x;
searcher._y = paperBoy._y;
if(Key.isDown(39))
{
this.rot = this.rot + 1;
}
else if(Key.isDown(37))
{
this.rot--;
}
if(Key.isDown(38))
{
this.acc = this.acc + 1;
}
else if(Key.isDown(40))
{
this.acc--;
}
}
else
{
this._visible = false;
viewingArrows._visible = true;
if(Key.isDown(39))
{
searcher._x += 20;
}
else if(Key.isDown(37))
{
searcher._x -= 20;
}
}
if(this.rot < 0.1 && this.rot > -0.1)
{
this.rot = 0;
}
if(this.arrow._rotation < -90)
{
this.rot *= -1;
this.arrow._rotation = -90;
}
else if(this.arrow._rotation > 0)
{
this.rot *= -1;
this.arrow._rotation = 0;
}
if(this.arrow.arrowBit._x < -15.5)
{
this.acc *= -0.5;
this.arrow.arrowBit._x = -15.5;
}
else if(this.arrow.arrowBit._x > 37.5)
{
this.acc *= -0.5;
this.arrow.arrowBit._x = 37.5;
}
this.rot *= 0.8;
this.acc *= 0.8;
this.arrow._rotation += this.rot;
this.arrow.arrowBit._x += this.acc;
this.arrow.arrowBit2._x = this.arrow.arrowBit._x;
if(Key.isDown(32))
{
sectionStart(4);
playFX("throw");
}
}
function movePaper()
{
this._x += this.Xacc - WXacc;
this._y += this.Yacc - WYacc;
this._rotation += this.rot;
this.rot *= 0.99;
this.relY += this.Yacc;
this.Xacc *= 0.993;
this.Yacc += 0.29;
if(this.relY > 360)
{
this.Yacc *= -0.5;
this.Xacc *= 0.8;
this.rot *= 0.8;
this._y -= this.rely - 360;
this.relY = 360;
this.bounce = this.bounce + 1;
_global.potScore -= mRd(mAb(this.Yacc));
playFX("hitGround");
}
if(mAb(this.Xacc) < 4 && this.bounce > 4)
{
_global.peopleScore = _global.peopleScore + 1;
scoreBar["icon" + _global.peopleScore].gotoandstop(3);
_root.sectionStart(5);
this.removeMovieClip();
}
var t = _root.attachMovie("paper","trail" + this.tNum,4700 + this.tNum);
t._x = this._x;
t._y = this._y;
t._rotation = this._rotation;
t._alpha = 20;
t.onenterframe = moveTrail;
if(++this.tNum > 20)
{
this.tNum = 0;
}
}
function addNextBuilding(oName, offset)
{
var s = _root.attachMovie(oName.title,oName.title + oName.nextBuild,oName.lev + oName.nextBuild);
s._y = s.relY = oName.curY;
s._x = 650 - offset;
s.num = oName.nextBuild;
s["class"] = oName;
s.gotoandstop(oName.aType[oName.nextBuild]);
oName.nextBuild = oName.nextBuild + 1;
s.onenterframe = move;
}
function addPrevBuilding(oName, offset)
{
var s = _root.attachMovie(oName.title,oName.title + oName.prevBuild,oName.lev + oName.prevBuild);
s._y = oName.curY;
s._x = -150 - offset;
s.num = oName.prevBuild;
s["class"] = oName;
s.gotoandstop(oName.aType[oName.prevBuild]);
oName.prevBuild--;
s.onenterframe = move;
}